<template>
  <el-card class="box-card">
    <el-table :data="tableData" style="width: 100%" max-height="800">
      <el-table-column fixed prop="_id" label="ID" width="450" />
      <el-table-column prop="userName" label="名称" width="430" />
      <el-table-column prop="productImage" label="头像" width="350">
        <template slot-scope="scope">
          <el-avatar shape="square" :size="size" :src="squareUrl" />
        </template>
      </el-table-column>
      <!-- <el-table-column fixed="right" label="操作" width="150">
        <template slot-scope="scope">
          <el-button
            type="text"
            size="small"
            @click.native.prevent="deleteRow(scope.$index, tableData)"
          >
            移除
          </el-button>
        </template>
      </el-table-column> -->
    </el-table>
  </el-card>
</template>

<script>
import { getUserList, delGoods } from '../../api/user'
export default {
  data() {
    return {
      tableData: []
    }
  },
  mounted() {
    getUserList().then((res) => {
      console.log(res)
      this.tableData = res.data.list
    })
  },
  methods: {
    deleteRow(index, rows) {
      console.log(index, rows)
      const data = {
        productId: rows[index].productId
      }
      console.log(data)
      delGoods(data).then((res) => {
        rows.splice(index, 1)
      })
    }
  }
}
</script>

<style scoped>
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  margin: 20px;
  width: 1280px;
  height: 600px;
}
</style>
